package com.testMain;


import java.util.Calendar;
import java.util.Scanner;

/**
 * @author 贾明祯
 * @ClassName ThreadTest
 * @Date 2020/9/23 9:58
 * @Introduce
 */
public class ThreadTest {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);

        System.out.println("请输入年份");
        String[] names = new String[]{"张三","李四","王五","赵六"};
        int year=scan.nextInt();

        int m=1;//月份计数
        int l = 0;
        int weekends = 0;
        while (m<13){
            int month=m;
            Calendar cal=Calendar.getInstance();//获得当前日期对象
            cal.clear();//清除信息
            cal.set(Calendar.YEAR,year);
            cal.set(Calendar.MONTH,month-1);//1月从0开始
            int count=cal.getActualMaximum(Calendar.DAY_OF_MONTH) ;
            int week=cal.get(Calendar.DAY_OF_WEEK);
            System.out.printf("\t\t\t%d年%d月\n\n",year,month);
            System.out.print("日\t一\t二\t三\t四\t五\t六\n");
            int i;

            for (i=0;i<week-1 ;i++){
                System.out.print("\t");
                weekends++;
            }

            for (int j=1;j<=count ;j++ ){
                if(l==names.length){
                    l=0;
                }
                if(weekends==0||weekends==6){
                    System.out.print(j+"W"+"\t");
                }else{
                    System.out.print(j+"\t");
                }

                l++;
                if ((i+j)%7==0){
                    System.out.println();
                }
                weekends++;
                if(weekends>6){
                    weekends=0;
                }
            }
            System.out.println();
            weekends=0;
            m++;
        }

    }
}
